package com.xxx.blog.service.impl;
import com.github.pagehelper.PageHelper;
import com.xxx.base.vo.GdVo;
import com.xxx.blog.domain.Article;
import com.xxx.blog.mapper.ArticleMapper;
import com.xxx.blog.query.ArticleQuery;
import com.xxx.blog.service.IArticleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ArticleImpl implements IArticleService {
    @Autowired
    ArticleMapper articleMapper;

    @Override
    public List<Article> findAll() {
        return articleMapper.findAll();
    }

    @Override
    public Article findOne(long id) {
        return articleMapper.findOne(id);
    }

    @Override
    public List<Article> queryPage(ArticleQuery articleQuery) {
        PageHelper.startPage(articleQuery.getCurrentPage(), articleQuery.getPageSize());
        List<Article> articles = articleMapper.queryPage(articleQuery);
        return articles;
    }

    @Override
    public void addArticle(Article article) {

        articleMapper.addArticle(article);
    }

    @Override
    public void updateArticle(Article article) {
        articleMapper.updateArticle(article);
    }

    @Override
    public void deleteArticle(long id) {
        articleMapper.deleteArticle(id);
    }

    @Override
    public void batchArticle(Long[] ids) {
        articleMapper.batchArticle(ids);
    }

    @Override
    public List<GdVo> getGd() {
        return articleMapper.getGd();
    }

    @Override
    public List<Article> getRa(long id) {
        Article one = articleMapper.findOne(id);

        return articleMapper.getRa(one);
    }


}
